home *** CD-ROM | disk | FTP | other *** search
- unit AutomationServer2ClassU;
-
- interface
-
- uses
- ComObj, ActiveX, AutomationServer2_TLB;
-
- type
- TClock = class(TAutoObject, IClock)
- private
- RegistrationCookie: Integer;
- protected
- function Get_DateAndTime: TDateTime; safecall;
- function Get_Visible: WordBool; safecall;
- procedure Set_Visible(Value: WordBool); safecall;
- procedure Quit; safecall;
- public
- procedure Initialize; override;
- destructor Destroy; override;
- end;
-
- implementation
-
- uses
- ComServ, SysUtils, Forms, Windows;
-
- procedure TClock.Initialize;
- begin
- inherited;
- OleCheck(RegisterActiveObject(Self as IUnknown, Class_Clock,
- ActiveObject_Weak, RegistrationCookie));
- Application.MainForm.Tag := Longint(Self);
- Application.MessageBox('COM object starting', 'Information',
- MB_OK or MB_ICONEXCLAMATION);
- end;
-
- destructor TClock.Destroy;
- begin
- Application.MessageBox('COM object ending', 'Information',
- MB_OK or MB_ICONEXCLAMATION);
- Application.MainForm.Tag := 0;
- OleCheck(RevokeActiveObject(RegistrationCookie, nil));
- inherited
- end;
-
- function TClock.Get_DateAndTime: TDateTime;
- begin
- Result := Now
- end;
-
- function TClock.Get_Visible: WordBool;
- begin
- Result := Application.MainForm.Visible
- end;
-
- procedure TClock.Set_Visible(Value: WordBool);
- begin
- Application.MainForm.Visible := Value;
- CoLockObjectExternal(Self as IUnknown, Value, True);
- end;
-
- procedure TClock.Quit;
- begin
- CoDisconnectObject(Self as IUnknown, 0);
- end;
-
- initialization
- TAutoObjectFactory.Create(ComServer, TClock, Class_Clock,
- ciSingleInstance, tmApartment);
- end.
-